<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="../dist/pandyle.js"></script>
    <title>Document</title>
</head>

<body>
    <div class="main">
        <div>{{name}}</div>
        <div>{{phone}}</div>
    </div>
    <div class="inputs">
        <div>
            <input type="text" name="name">
            <input type="text" name="phone">
            <input type="text" value="这是没用的数据">
        </div>
        <div>
            <input type="checkbox" name="swiches.s1">开关一
            <input type="checkbox" name="swiches.s2">开关二
        </div>
        <div>
            <p><input type="checkbox" name="attr.hobby" value="游泳">游泳</p>
            <p><input type="checkbox" name="attr.hobby" value="篮球">篮球</p>
            <p><input type="checkbox" name="attr.hobby" value="足球">足球</p>
        </div>
    </div>

    <button onclick="print()">打印数据</button>
    <button onclick="changeData()">设置数据而不触发change事件</button>
    <button onclick="refresh()">手动刷新inputs</button>

    <script>
        var vm = $('.main').vm({ name: '', phone: '' });
        var inputs = $('.inputs').inputs();
        // inputs.callBack = function (name, value) {
        //     vm.set(name, value);
        // }

        function print() {
            console.log(inputs);
        }

        function changeData(){
            $('[name=phone]').val('13800000000');
        }

        function refresh(){
            inputs.refresh();
        }
    </script>
</body>

</html>